VERSION 5.00
Begin VB.Form frmSendMail 
   Caption         =   "שלח מייל"
   ClientHeight    =   7920
   ClientLeft      =   120
   ClientTop       =   420
   ClientWidth     =   5760
   LinkTopic       =   "Form1"
   ScaleHeight     =   7920
   ScaleWidth      =   5760
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox txtPDFTimeout 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   1080
      RightToLeft     =   -1  'True
      TabIndex        =   23
      Text            =   "10000"
      Top             =   6840
      Width           =   1815
   End
   Begin VB.TextBox txtCC 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   240
      RightToLeft     =   -1  'True
      TabIndex        =   19
      ToolTipText     =   "השתמש בפסיק להפריד בין הכתובות"
      Top             =   840
      Width           =   4335
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "יציאה"
      Height          =   375
      Left            =   240
      TabIndex        =   18
      Top             =   7440
      Width           =   1455
   End
   Begin VB.TextBox txtPassword 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   360
      RightToLeft     =   -1  'True
      TabIndex        =   16
      Top             =   6360
      Width           =   1215
   End
   Begin VB.TextBox txtUserName 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   2400
      RightToLeft     =   -1  'True
      TabIndex        =   14
      Top             =   6360
      Width           =   1815
   End
   Begin VB.TextBox txtInvoiceNumber 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   1920
      RightToLeft     =   -1  'True
      TabIndex        =   12
      Top             =   5400
      Width           =   2535
   End
   Begin VB.TextBox txtMailServer 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   1920
      RightToLeft     =   -1  'True
      TabIndex        =   10
      ToolTipText     =   "שרת הדואר. לדוגמה: out.bezeqint.net"
      Top             =   5880
      Width           =   2535
   End
   Begin VB.TextBox txtFromName 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   240
      RightToLeft     =   -1  'True
      TabIndex        =   9
      ToolTipText     =   "שם ידידותי כמו כספית תוכנה בע""מ"
      Top             =   1320
      Width           =   1695
   End
   Begin VB.TextBox txtFrom 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   2760
      RightToLeft     =   -1  'True
      TabIndex        =   7
      ToolTipText     =   "כתובת המייל"
      Top             =   1320
      Width           =   1815
   End
   Begin VB.TextBox txtTo 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   240
      RightToLeft     =   -1  'True
      TabIndex        =   5
      ToolTipText     =   "השתמש בפסיק להפריד בין הכתובות"
      Top             =   360
      Width           =   4335
   End
   Begin VB.TextBox txtSubject 
      Alignment       =   1  'Right Justify
      Height          =   285
      Left            =   240
      RightToLeft     =   -1  'True
      TabIndex        =   3
      Top             =   1920
      Width           =   4335
   End
   Begin VB.TextBox txtBody 
      Alignment       =   1  'Right Justify
      Height          =   2295
      Left            =   120
      MultiLine       =   -1  'True
      RightToLeft     =   -1  'True
      TabIndex        =   2
      ToolTipText     =   "טקסט HTML שאתה רוצה לשלוח"
      Top             =   2760
      Width           =   5295
   End
   Begin VB.CommandButton cmdSendInvoice 
      Caption         =   "שלח חשבונית"
      Height          =   375
      Left            =   4080
      TabIndex        =   1
      Top             =   7440
      Width           =   1455
   End
   Begin VB.CommandButton cmdSend 
      Caption         =   "שלח מייל"
      Height          =   375
      Left            =   2520
      TabIndex        =   0
      Top             =   7440
      Width           =   1455
   End
   Begin VB.Label Label5 
      Alignment       =   1  'Right Justify
      Caption         =   "המתן למדפסת (מילי שניות):"
      Height          =   255
      Left            =   3120
      RightToLeft     =   -1  'True
      TabIndex        =   24
      Top             =   6840
      Width           =   2295
   End
   Begin VB.Label Label10 
      Alignment       =   1  'Right Justify
      Caption         =   "גוף המייל (HTML):"
      Height          =   255
      Left            =   3600
      RightToLeft     =   -1  'True
      TabIndex        =   22
      Top             =   2400
      Width           =   1815
   End
   Begin VB.Label Label9 
      Alignment       =   1  'Right Justify
      Caption         =   "שם:"
      Height          =   255
      Left            =   2280
      RightToLeft     =   -1  'True
      TabIndex        =   21
      Top             =   1320
      Width           =   375
   End
   Begin VB.Label Label8 
      Alignment       =   1  'Right Justify
      Caption         =   "העתק:"
      Height          =   255
      Left            =   4680
      RightToLeft     =   -1  'True
      TabIndex        =   20
      Top             =   840
      Width           =   735
   End
   Begin VB.Label Label7 
      Alignment       =   1  'Right Justify
      Caption         =   "סיסמה:"
      Height          =   255
      Left            =   1560
      RightToLeft     =   -1  'True
      TabIndex        =   17
      Top             =   6360
      Width           =   735
   End
   Begin VB.Label Label6 
      Alignment       =   1  'Right Justify
      Caption         =   "שם המשתמש:"
      Height          =   255
      Left            =   4320
      RightToLeft     =   -1  'True
      TabIndex        =   15
      Top             =   6360
      Width           =   1095
   End
   Begin VB.Label lblInvoice 
      Alignment       =   1  'Right Justify
      Caption         =   "חשבונית:"
      Height          =   255
      Left            =   4680
      RightToLeft     =   -1  'True
      TabIndex        =   13
      Top             =   5400
      Width           =   735
   End
   Begin VB.Label Label4 
      Alignment       =   1  'Right Justify
      Caption         =   "שרת דואר:"
      Height          =   255
      Left            =   3960
      RightToLeft     =   -1  'True
      TabIndex        =   11
      Top             =   6000
      Width           =   1455
   End
   Begin VB.Label Label3 
      Alignment       =   1  'Right Justify
      Caption         =   "מאת:"
      Height          =   255
      Left            =   4680
      RightToLeft     =   -1  'True
      TabIndex        =   8
      Top             =   1320
      Width           =   735
   End
   Begin VB.Label Label2 
      Alignment       =   1  'Right Justify
      Caption         =   "*אל:"
      Height          =   255
      Left            =   4680
      RightToLeft     =   -1  'True
      TabIndex        =   6
      Top             =   360
      Width           =   735
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      Caption         =   "*נושא:"
      Height          =   255
      Left            =   4680
      RightToLeft     =   -1  'True
      TabIndex        =   4
      Top             =   1920
      Width           =   735
   End
End
Attribute VB_Name = "frmSendMail"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Const MOD_NAME = "frmSendMail."

Private Sub cmdExit_Click()
Const FUNC_NAME = MOD_NAME & "cmdExit_Click"
On Error GoTo func_err
    SaveSetting APP_NAME, "SendMail", "txtBody", txtBody
    SaveSetting APP_NAME, "SendMail", "txtCC", txtCC
    SaveSetting APP_NAME, "SendMail", "txtFrom", txtFrom
    SaveSetting APP_NAME, "SendMail", "txtFromName", txtFromName
    SaveSetting APP_NAME, "SendMail", "txtInvoiceNumber", txtInvoiceNumber
    SaveSetting APP_NAME, "SendMail", "txtMailServer", txtMailServer
    SaveSetting APP_NAME, "SendMail", "txtPassword", txtPassword
    SaveSetting APP_NAME, "SendMail", "txtSubject", txtSubject
    SaveSetting APP_NAME, "SendMail", "txtTo", txtTo
    SaveSetting APP_NAME, "SendMail", "txtUserName", txtUserName
    SaveSetting APP_NAME, "SendMail", "txtPDFTimeout", txtPDFTimeout
    
    Unload Me
Exit Sub

func_err:
    MyErrMsgBox "Error " & Err.Number & " in " & Err.Source & ": " & Err.Description
End Sub

Private Sub cmdSend_Click()
Const FUNC_NAME = MOD_NAME & "cmdSend_Click"
On Error GoTo func_err
    Dim objCaspit As CaspitAPI.Caspit
    
    If LenB(txtTo) = 0 Then
        MyErrMsgBox "חובה להכניס מייל"
        txtTo.SetFocus
        Exit Sub
    End If
    If LenB(txtSubject) = 0 Then
        MyErrMsgBox "חובה להכניס נושא"
        txtSubject.SetFocus
        Exit Sub
    End If
    
    Set objCaspit = New CaspitAPI.Caspit
    With objCaspit
        .CaspitPath = g_strCaspitPath
        .DebugMode = g_blnDebug
        .MailServer = txtMailServer
        .MailServerPassword = txtPassword
        .MailServerUserName = txtUserName
    End With
    
    Screen.MousePointer = vbHourglass
    
    objCaspit.SendMail txtSubject & " " & Now(), _
        txtFrom, txtFromName, _
        txtTo, txtCC, "", _
        txtBody
        
    Screen.MousePointer = vbDefault
    MyMsgBox "המייל נשלח בהצלחה"
Exit Sub

func_err:
    Screen.MousePointer = vbDefault
    MyErrMsgBox "Error " & Err.Number & " in " & Err.Source & ": " & Err.Description
End Sub

Private Sub cmdSendInvoice_Click()
Const FUNC_NAME = MOD_NAME & "cmdSend_Click"
On Error GoTo func_err
    Dim objCaspit As CaspitAPI.Caspit
    
   
    If LenB(txtTo) = 0 Then
        MyErrMsgBox "חובה להכניס מייל"
        txtTo.SetFocus
        Exit Sub
    End If
    If LenB(txtSubject) = 0 Then
        MyErrMsgBox "חובה להכניס נושא"
        txtSubject.SetFocus
        Exit Sub
    End If
        
    If LenB(txtInvoiceNumber) = 0 Then
        MyErrMsgBox "חובה להכניס מספר חשבונית"
        txtSubject.SetFocus
        Exit Sub
    End If
        
    Set objCaspit = New CaspitAPI.Caspit
    With objCaspit
        .CaspitPath = g_strCaspitPath
        .DebugMode = g_blnDebug
        .MailServer = txtMailServer
        .MailServerPassword = txtPassword
        .MailServerUserName = txtUserName
        .PDFTimeout = CDbl(txtPDFTimeout)
    End With
    
    Screen.MousePointer = vbHourglass
    objCaspit.SendDocByMail CLng(txtInvoiceNumber), Invoice, txtSubject, _
        txtFrom, txtFromName, _
        txtTo, txtCC, "", _
        txtBody
    
    Screen.MousePointer = vbDefault
    MyMsgBox "החשבונית נשלחה בהצלחה"
Exit Sub

func_err:
    Screen.MousePointer = vbDefault
    MyErrMsgBox "Error " & Err.Number & " in " & Err.Source & ": " & Err.Description
End Sub

Private Sub Form_Load()
Const FUNC_NAME = MOD_NAME & "cmdSend_Click"
On Error GoTo func_err

    txtBody = GetSetting(APP_NAME, "SendMail", "txtBody", txtBody)
    txtTo = GetSetting(APP_NAME, "SendMail", "txtTo", txtTo)
    txtCC = GetSetting(APP_NAME, "SendMail", "txtCC", txtCC)
    txtFrom = GetSetting(APP_NAME, "SendMail", "txtFrom", txtFrom)
    txtFromName = GetSetting(APP_NAME, "SendMail", "txtFromName", txtFromName)
    txtInvoiceNumber = GetSetting(APP_NAME, "SendMail", "txtInvoiceNumber", txtInvoiceNumber)
    txtMailServer = GetSetting(APP_NAME, "SendMail", "txtMailServer", txtMailServer)
    txtPassword = GetSetting(APP_NAME, "SendMail", "txtPassword", txtPassword)
    txtPassword = GetSetting(APP_NAME, "SendMail", "txtPassword", txtPassword)
    txtSubject = GetSetting(APP_NAME, "SendMail", "txtSubject", txtSubject)
    txtUserName = GetSetting(APP_NAME, "SendMail", "txtUserName", txtUserName)
    txtPDFTimeout = GetSetting(APP_NAME, "SendMail", "txtPDFTimeout", txtPDFTimeout)

Exit Sub

func_err:
    MyErrMsgBox "Error " & Err.Number & " in " & Err.Source & ": " & Err.Description
End Sub
